<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>生成器解决异步编程</title>
</head>
<body>
    <script>
        function * gen(arg){
            console.log(arg);
           let a =  yield  111;
           console.log(a);
           let b = yield  222;
           console.log(b);
           let c = yield  333;
           console.log(a);
        }
        // 执行获取迭代器对象
        let iterator = gen('AAA');
        console.log(iterator.next());
        // next方法可以传入实参
        console.log(iterator.next('BBB'));
        // console.log(iterator.next('CCC'));
        // console.log(iterator.next('DDD'));

    </script>
</body>
</html>